package com.tzj.pic;

import com.tzj.tg.BasePicture;
import com.tzj.tg.Config;
import com.tzj.tg.Destroyable;
import com.tzj.tg.Hitable;

/**
 * @author honeyrr
 * 爆炸
 */
public class Blast extends BasePicture implements Destroyable{
	
	private String[] blasts = Config.SMALL_BLASTS;
	private int index; // 索引
	public Blast(Hitable hit, boolean b) {
		int[] size = Config.getImgSize(Config.SMALL_BLASTS[0]);
		this.width = size[0];
		this.height = size[1];
		
		BasePicture bp = (BasePicture) hit;
		this.x = bp.x - (this.width - bp.width) / 2;
		this.y = bp.y - (this.height - bp.height) / 2;
		
		
		
		if (b) {
			blasts = Config.BIG_BLASTS;
		}
	}

	@Override
	protected void draw() {
		if (this.index >= blasts.length) {
			return;
		}
		Config.draw(blasts[this.index++], x, y);
	}

	@Override
	public boolean isDestroyed() {
		return this.index >= blasts.length;
	}

}
